function login() {
	if (!$("#userName").val()) {
		_alert("请输入用户名");
		return false;
	}

	if (!$("#password").val()) {
		_alert("请输入密码");
		return false;
	}
	var host = $("#host").val();
	bmsAjaxForm($("#loginForm"), {
		dataType : 'json',
		beforeSend : function() {
			showProccessBar();
		},
		complete : function() {
			hideProccessBar();
		},
		success : function(data) {
			if (data.code == 0) {
				var url = _HOST_URL;
				if (url.indexOf(";") > 0) {
					var array = url.split(";");
					url = array[0] + data.result + ";" + array[1];
				} else {
					url += data.result;
				}

				document.write("<form action='" + url + "' method='post' name='formx1' style='display:none'>");
				document.write("<input type='hidden' name='host' value='" + host + "' />");
				document.write("</form>");
				document.formx1.submit();
			} else if (data.code == 1) {
				_alert(data.message);
			}
		}
	});
}

function isChrome() {
	if (document.browser.name !== 'Chrome') {
		var $chrome_tip = $('<div></div>');
		$chrome_tip.addClass('login-header-tip');
		$chrome_tip.html('建议使用<span>谷歌浏览器</span>');
		$(".login-header-box").prepend($chrome_tip);

		var chrome_download_url;
		if (document.os.name === 'Mac') {
			chrome_download_url = "https://www.baidu.com/link?url=fpHLYlwbQM2xTVJ1zr1O0nJifJ-DZYiUml0hQh751OtRn-NNieAxc6vPgSGh8Ll7afSS8jk_c-wT21lr-ZwRYLjsTRrFxG79YlxnrHzn-3m&amp;wd=&amp;eqid=b39cecc0000109440000000459e997da";
		} else {
			chrome_download_url = "https://www.baidu.com/link?url=1rqA9KjGzjH8U0D6dvHRtqLbjXwtTjShRMkSt2a-Bhki8rmWKfWBhs6c2XmHDqGjxvdcqtcCIN4i7Wza01nYTTBXsaXyKi4jyV9-eh_Ca5_&amp;wd=&amp;eqid=b39cecc0000109440000000459e997da&amp;qq-pf-to=pcqq.temporaryc2c";
		}
		$chrome_tip.find("span").click(function() {
			window.open(chrome_download_url);
		});
	}

}
$(function() {
	var url = window.location.href;
	var urlName = url.indexOf(".");
	var dicName = "";
	if (urlName != -1) {
		dicName = url.substring(7, urlName);
		$("#loginUrl").val(dicName);
	}

	isChrome();
	/**
	 * 获取CSS文本
	 * 
	 * @param {String}
	 *            imgSrc 背景图片路径
	 * @returns {String} 返回CSS文本
	 */
	function getCssTxt(imgSrc) {
		var cssTxt = '.login-page .skin-box-bd{background-image:url("' + imgSrc + '");}';
		return cssTxt;
	}
	var serverUrl = _SERVER_URL;
	var Enterprise = _ENTERPRISE;
	var proInfos = _PRO_INFOS;
	if (Enterprise) {
		if (Enterprise.slogn) {
			$("#href0").text(Enterprise.slogn);
			$("#href0").css({
				'font-size' : '44px',
				'color' : 'white',
				'width' : '800px',
				'padding-top' : '178px',
				'text-align' : 'center',
				'text-decoration' : 'none'
			})
		}
		if (Enterprise.slogn) {
			$("#id").text(Enterprise.slogn);
			$("#id").css({
				'font-size' : '44px',
				'color' : 'white',
				'width' : '800px',
				'padding-top' : '178px',
				'text-align' : 'center',
				'text-decoration' : 'none'
			})
		}
		if (Enterprise.bgURL) {
			var obj = $('#pro0');
			obj.css('backgroundImage', "url(" + Enterprise.bgURL + ")");
		} else {
			var obj = $('#pro0');
			obj.css('backgroundImage', "url(css/img/banner/pic1.jpg)");
		}
		if (Enterprise.personalIcon) {
			$("#logo-icon").css('backgroundImage', "url()");
			$("#logo-icon").append("<img id='tempImgLarge' src='" + Enterprise.personalIcon + "' style='width:40px;height:40px;'/>");
		}
	}
	if (proInfos) {
		$.each(proInfos, function(index) {
			var realIndex = index;
			if (Enterprise && Enterprise.bgURL) {
				realIndex = index + 1;
			}
			if (Enterprise && !Enterprise.bgURL) {
				realIndex = index + 1;
			}
			//console.log(serverUrl + proInfos[index].imgUrl);
			var obj = $('#pro' + realIndex);
			obj.css('backgroundImage', "url(" + serverUrl + proInfos[index].imgUrl + ")");
			obj.css('cursor', 'pointer');
			var hrObj = $('#href' + realIndex);
			//console.log(proInfos[index].url);
			hrObj.click(function() {
				window.open(proInfos[index].url);
				return false;
			});
		});
	}
});